package com.darrenchan.netease03

trait Handler {
  def handler() = {}
}

trait HandlerA extends Handler {
  override def handler(): Unit = {
    println("A")
    super.handler()
  }
}

trait HandlerB extends Handler {
  override def handler(): Unit = {
    println("B")
    super.handler()
  }
}

trait HandlerC extends Handler {
  override def handler(): Unit = {
    println("C")
    super.handler()
  }
}

//从右往左调用
class HandlerTest extends HandlerC with HandlerB with HandlerA {
  def sayHello() = {
    println("say hello")
    handler()
  }
}


object Trait_Chain {
  def main(args: Array[String]): Unit = {
    val hh = new HandlerTest()

    /**
      * say hello
      * A
      * B
      * C
      */
    hh.sayHello()
  }
}
